package offer;

public class Offer3 {

    class Solution0 {
        public int findRepeatNumber(int[] nums) {
            byte[] bitmap = new byte[nums.length];
            for (int num : nums) {
                if (bitmap[num] == 1) {
                    return num;
                }
                bitmap[num] = 1;
            }
            return -1;
        }
    }

    class Solution {
        public int findRepeatNumber(int[] nums) {
            int n = 0;
            for (int num : nums) {
                if ((1 << num & n) != 0) {
                    return num;
                }
                n = n | 1 << num;
            }
            return -1;
        }
    }
}
